<template>
  <div class="adminqianming">
    <admin_top></admin_top>
    <div style="padding:0 20px 20px 20px" class="t_btn_box">
      <el-input style="width:180px" size="small" v-model="all.shop_name" placeholder="请输入店铺名称"></el-input>
      <el-button @click="search" size="small" type="danger">搜索</el-button>
    </div>
    <div style="padding: 0 20px;">
      <el-table :data="tableData" style="text-align: center;" align="center" border :loading="loading">
        <el-table-column label="店铺名">
          <template slot-scope="scope">
            <span>{{ scope.row.shop_name }}</span>
          </template>
        </el-table-column>
        <el-table-column label="来源">
          <template slot-scope="scope">
            <span>{{ scope.row.source }}</span>
          </template>
        </el-table-column>
        <el-table-column label="是否加白">
          <template slot-scope="scope">
            <span v-if="scope.row.is_white == 0">未加白</span>
            <span v-if="scope.row.is_white == 1">已加白</span>
          </template>
        </el-table-column>

        <el-table-column label="来源">
          <template slot-scope="scope">
            <span>{{ scope.row.source }}</span>
          </template>
        </el-table-column>

        <el-table-column label="操作">
          <template slot-scope="scope">

            <el-button type="text" v-if="scope.row.is_white == 0 && scope.row.source == 'douyin'"
              @click="tuikuan(scope.row,1)">加白</el-button>
            <el-button type="text" v-if="scope.row.is_white == 1 && scope.row.source == 'douyin'"
              @click="tuikuan(scope.row,0)">取消加白</el-button>



          </template>
        </el-table-column>
      </el-table>
      <div class="fenye" style="padding: 20px; text-align: right;">
        <el-pagination background layout="prev, pager, next" @current-change="fanye" :page-size="all.page_size"
          :total="total"></el-pagination>
      </div>
    </div>



  </div>
</template>

<script>
  import admin_top from './top.vue';
  import axios from 'axios'
  export default {
    components: {
      admin_top
    },
    name: 'adminqianming',
    data() {
      return {
        all: {
          shop_name: '',
          page_size: 200,
          page: 1,
        },
        tableData: "",
        total: "",
        loading: true,
        feigeall: {
          shop_id: "",
          name: "",
          sign: ""
        },
        log: false,
        log2: false,
        tableData2: "",
        feigeall2:{
          id:"",
          sign: "",
          shop_id: "",
        },
        log3:false
      }
    },
    watch: {

    },
    computed: {

    },
    created() {
      this.getlist()
    },
    methods: {

      tuikuan: function(item, val) {
        this.$confirm('确定加白吗', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(() => {

          axios.post('/api/plan-market/admin/outer-store/set', {
              is_white: val,
              store_id: item.id
            })
            .then(response => {
              if (response.data.msg.code == 0) {
                this.$message.success('操作成功');
                this.getlist()
              } else {
                this.$message.error(response.data.msg.info);
              }
            })
        })


      },
      //翻页
      fanye: function(page) {
        this.loading = true
        this.all.page = page
        this.getlist()
      },
      //获取全部
      getlist: function() {
        var that = this
        axios.get('/api/plan-market/admin/outer-store/list', {
            params: this.all
          })
          .then(response => {
            if (response.data.msg.code == 0) {
              this.tableData = response.data.data
              this.loading = false
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      //搜索
      search() {
        //获取列表
        this.getlist()
      },

    },

  }
</script>

<style scoped>
  .adminqianming {
    background: #EAEAEA;
    min-height: 100vh;
    padding: 0px;
  }

  .t_btn_box {
    display: flex;
    justify-content: flex-end;
  }
</style>
